<script>
<!--
$(document).ready(function()
{
	$('input').keydown(function(evt) {
		evt = (evt) ? evt : event;
		var charCode = (evt.charCode) ? evt.charCode :
			((evt.which) ? evt.which : evt.keyCode);
		if (charCode == 13) {
			return false;
		} else {
			return true;
		}
	});

	$('input[name="Firms[title]"]').keydown(function(evt) {
		evt = (evt) ? evt : event;
		var charCode = (evt.charCode) ? evt.charCode :
			((evt.which) ? evt.which : evt.keyCode);
		if (charCode == 13) {
			$('input[name="Firms[title]"]').change();
			return false;
		} else {
			return true;
		}
	});

});
-->
</script>

<h1>Управление организациями</h1>

<!-- new -->
<?php echo CHtml::htmlButton('Добавить организацию',
		array('onclick'=> 'javascript:window.location="index.php?r=admin/firms/create";')
	);
?>


<!-- admin -->
<?php echo CHtml::beginForm("index.php?r=admin/firms/saveall", "post"); ?>
<?php $this->widget('zii.widgets.grid.CGridView', array(
	'id'=>'sections-grid',
	'dataProvider'=>$model->search(),
	'filter'=>$model,
	'columns'=>array(
		array(
			'name'=>'id',
			'filter'=>false,
		),
		array(
			'name'=>'id_icon',
			'value'=>'$data->id_icon ? CHtml::image(
				"uploads/".Uploads::Model()->FindByPk($data->id_icon)->file_name, "", array("height"=>"75px")) : ""',
			'filter'=>false,
			'type'=>'raw'
		),
		array(
			'name'=>'title',
		),

		array(
			'name'=>'id_section',
			'value'=>'Sections::Model()->FindByPk($data->id_section)->name',
			'filter'=>CHtml::listData(Sections::model()->findAll(array('order'=>'order_id ASC')), 'id', 'name'),
		),

		array(
			'name'=>'order_id',
			'value'=>'CHtml::textField("item[".$data->id."][order]", $data->order_id, array("size"=>"5"))',
			'filter'=>false,
			'type'=>'raw',
		),
		
		array(
			'name'=>'enabled',
			'value'=>'CHtml::checkBox("item[".$data->id."][enabled]", $data->enabled)',
			'filter'=>false,
			'type'=>'raw',
		),

		array(
			'class'=>'CButtonColumn',
			'template'=>'{view} {update} {delete}',
			'buttons'=>array (
				'view' => array (
					'label'=>'view',					
					'url'=>'Yii::app()->createUrl("site/view", array("id"=>$data->id, "id_section"=>$data->id_section))',
					'options'=>array('target'=>'_balnk'),
				),
			),
		),
	),
)); ?>
<br />
<?php echo CHtml::submitButton('Сохранить изменения'); ?>
<?php echo CHtml::endForm(); ?>
<br />


